Skip to content

fix: stripRichTextMarkup must not corrupt Mermaid node syntax#4

Closed
NeoVand wants to merge 1 commit into
mainfrom
improvement-pass-1
Closed

fix: stripRichTextMarkup must not corrupt Mermaid node syntax#4
NeoVand wants to merge 1 commit into
mainfrom
improvement-pass-1

Conversation

@NeoVand

@NeoVand NeoVand commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Follow-up fix to the quality pass (#3, already merged).

The bare-ref change in #3 regressed Mermaid diagrams: Mermaid reuses {{…}}
(hexagon) and [[…]] (subroutine) for node shapes — e.g. the Transport
category story has T3{{"Middlebox"}}. stripRichTextMarkup (which also cleans
Mermaid node labels) turned that into T3"Middlebox", invalid Mermaid, so the
diagram failed to render ("Diagram unavailable").

Fix: only resolve a bare ref when its id is slug-shaped (lowercase
kebab/colon, REF_ID). Non-slug {{…}} / [[…]] — quotes, spaces, capitals,
i.e. Mermaid syntax — pass through untouched. This also fixes the pre-existing
silent loss of those labels: the "Middlebox" hexagon now renders with its label.

Added regression tests; verified the Transport category-story diagram renders
again with a clean console.

🤖 Generated with Claude Code

Regression from the bare-ref strip change: Mermaid reuses {{…}} (hexagon) and
[[…]] (subroutine) for node *shapes* — e.g. a story diagram with
`T3{{"Middlebox"}}`. The new fallback turned that into `T3"Middlebox"`, invalid
Mermaid, so the diagram failed to render ("Diagram unavailable").

Fix: only resolve a bare ref when its id is slug-shaped (REF_ID:
lowercase kebab/colon). Non-slug `{{…}}` / `[[…]]` (quotes, spaces, capitals =
Mermaid syntax) pass through untouched. This also fixes the *pre-existing*
silent loss of those labels — the "Middlebox" hexagon now renders correctly.

Added regression tests; verified the Transport category-story diagram renders
again, console clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@NeoVand

NeoVand commented Jun 19, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #5, which includes this Mermaid fix plus the new force layout. Closing to consolidate into a single PR.

@NeoVand NeoVand closed this Jun 19, 2026
@NeoVand NeoVand deleted the improvement-pass-1 branch June 19, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant